package k.dao.base;

import k.dto.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
/**
 * Created by sure
 */
@Component
public class RoleDao {
    private String sql;
    @Autowired
    BaseDao baseDao;
    public List<Role> findAll(){
        sql = "SELECT * FROM `role`";
        return baseDao.query(sql,Role.class);
    }

    public  Role querybyId(String role_id){
        sql = "select * from role where role_id = ?";
        return baseDao.queryById(sql,Role.class,role_id);
    }


    public void upd(Role role){
        sql = "UPDATE `bitserver`.`role` SET  `role_name`=:role_name WHERE (`role_id`=:role_id)" ;
        baseDao.update(sql,role);
    }
}
